<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
//    Object.defineProperty 可以用来数据劫持
let obj = {
  age: 10,
  name: '张三'
}

// Object.(obj,'name',{

// })
// target 就是你要监听的对象 handler 监听对象的选项
let obj1 = new Proxy(obj,{
  get(val){
    if(val.name=="张三"){
      return '李四'
    } else {
      return 200
    }
  },
  set(val,value,val1){
    return val[value] = val1
  }
});
obj1.age = 30;
console.log(obj1.name);
</script>